package com.iwdnb.gkgz.ui.controller;

import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;

import cn.hutool.core.date.DateUtil;
import com.google.common.collect.Lists;
import com.iwdnb.bmnf.common.model.result.Result;
import com.iwdnb.bmnf.common.service.CacheService;
import com.iwdnb.gkgz.application.model.vo.StockType;
import com.iwdnb.gkgz.application.service.HistoryDataService;
import com.iwdnb.gkgz.application.service.StockDayDataSerivce;
import com.iwdnb.gkgz.application.service.StockService;
import com.iwdnb.gkgz.common.model.dto.Stock;
import com.iwdnb.gkgz.common.model.dto.StockDayData;
import com.iwdnb.gkgz.infrastructure.dao.client.MairuiClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 股票指数数据处理
 **/
@RestController
@RequestMapping("/api/stock/zs")
@Slf4j
public class StockZsController {

    @Autowired
    private MairuiClient mairuiClient;
    @Autowired
    private Executor executor;

    /**
     * 加载指数日K线数据
     *
     * @param code
     * @return
     */
    @RequestMapping("/loadZsStockDayData")
    public Result<String> loadZsStockDayData(String code) {
        List<String> codes = Lists.newArrayList(code.split(","));
        for (String c : codes) {
            executor.execute(() -> {
                mairuiClient.initZsStockDayDataList(c);
            });
        }
        return Result.getSuccessResult(null);
    }

}
